
function AlgDeep (move) {
  this._reevaluateWays = this._reevaluateWays3;
  this._evaluate = this._evaluate2;
  this._evaluateFast = this._evaluateFast2;
  this.PIECE_VALUE_THRESHOLD = 0.3;
  this.PIECE_VALUE_MAX = 15;
  
}

AlgDeep.prototype = AlgCluster.prototype;



AlgDeep.prototype._reevaluateWays3 = function(ways, move) {
  var backupWay = ways[0];
  var newWays = new Array();
  var myPotentialMove = new Move(move.board, move.color, -1, move.validator, Algorithm.prototype.cloneCallback);
  for (w = 0; w < ways.length; w++) {
    way = ways[w];    
    if (this._tryToUpdateMove(way, myPotentialMove)) {
      
      myPotentialMove.complete();
      if (myPotentialMove.winningColor == myPotentialMove.color) {
        newWays.push(way);
      } else if (myPotentialMove.winningColor != OPPOSITE_COLOR[myPotentialMove.color]) {
	      
	      var nextMove = new Move(myPotentialMove.board, OPPOSITE_COLOR[myPotentialMove.color], -1, myPotentialMove.validator);
	      var alg = new AlgCluster();
	      alg.makeMove(nextMove);
	      nextMove.complete();
	      if (nextMove.winningColor == myPotentialMove.color) {
	        newWays.push(way);
	      } else if (nextMove.winningColor != OPPOSITE_COLOR[myPotentialMove.color]) {
	        way.value = -alg._evaluateFast2(nextMove.board, nextMove.color);
	        newWays.push(way);
	      } else {
	        //alert("Oh-oh - losing game!");
	      }
	      
	  }     
    }
    myPotentialMove.reset();
  }
  //alert("was = " + ways.length + " now = " + newWays.length);
  //if (newWays.length == 0) {
  //  newWays.push(backupWay);
  //}
  return newWays;
}
  
toTest.push(AlgDeep);

AlgDeep.prototype.test = function() {
}
